package mess;

import java.util.*;

public class LeeCode_982 {
    public static void main(String[] args) {
        System.out.println(countTriplets(new int[]{0, 0, 0}));
        List<Integer> list = new ArrayList<>();
    }

    private static int countTriplets(int[] nums) {
        int len = nums.length;
        Map<Integer, Integer> map = new HashMap<>();
        int count = 0;
        for(int i = 0; i < len; i++){
            for(int j = 0;j < len ; j ++){
                int num = nums[i] & nums[j];
                if(map.containsKey(num)){
                    map.put(num, map.get(num) + 1);
                }else{
                    map.put(num, 1);
                }
            }
        }
        Set<Integer> keys = map.keySet();
        for(Integer key: keys){
            for(int i = 0; i < len; i++){
                if((key & nums[i]) == 0){
                    count += map.get(key);
                }
            }
        }
        return count;
    }
}
